const Subscription = require("egg").Subscription;

class ForwardTaskClear extends Subscription {
  // 每30秒执行一次
  static get schedule() {
    return {
      cron: '0 0 9 * * *',
      type: "worker",
    };
  }

  async subscribe() {
    const { ctx } = this;
    try {
      await ctx.model.Forwardtask.deleteMany({ status: 1 });
    } catch (error) {
      ctx.logger.error(`任务清理失败: ${error.message}`);
    }
  }
}

module.exports = ForwardTaskClear;
